CREATE TABLE [dbo].[TRCNTA_EMPR]
(
[CO_EMPR] [dbo].[TD_VC_002] NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NULL CONSTRAINT [DF__TRCNTA_EM__NU_AN__753864A1] DEFAULT (datepart(year,getdate())),
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NULL,
[NU_ANNO_ANTE] [dbo].[TD_IN_004_ANNO] NULL CONSTRAINT [DF__TRCNTA_EM__NU_AN__7814D14C] DEFAULT (datepart(year,getdate())),
[CO_CNTA_ANTE] [dbo].[TD_VC_020_CNTA] NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TRCNTA_EM__FE_US__7AF13DF7] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TRCNTA_EM__FE_US__7BE56230] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TRCNTA_EMPR] ADD CONSTRAINT [CK__TRCNTA_EM__CO_CN__7720AD13] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TRCNTA_EMPR] ADD CONSTRAINT [CK__TRCNTA_EM__CO_CN__79FD19BE] CHECK (([CO_CNTA_ANTE]>='0' AND [CO_CNTA_ANTE]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TRCNTA_EMPR] ADD CONSTRAINT [CK__TRCNTA_EM__NU_AN__762C88DA] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TRCNTA_EMPR] ADD CONSTRAINT [CK__TRCNTA_EM__NU_AN__7908F585] CHECK (([NU_ANNO_ANTE]>=(0)))
GO
ALTER TABLE [dbo].[TRCNTA_EMPR] ADD CONSTRAINT [TMPLAN_ANNO_A_TRCNTA_EMPR] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
